package tech.aistar.wyymusicplayer.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tech.aistar.wyymusicplayer.pojo.PlayListDetails;
import tech.aistar.wyymusicplayer.pojo.Song;

import java.util.List;

/**
 * ClassName: PlayListMapper
 * Package: tech.aistar.wyymusicplayer.mapper
 * Description:
 *
 * @Author: JMOOL
 * @Create: 2025/3/6-08:45
 * @Version: v1.0
 */
public interface PlayListDetailsMapper {

    /**
     * 根据歌单id进行查询
     * @param id
     * @return
     */
    @Select("select * from playlist where id=#{value}")
    PlayListDetails getPlayLists(Integer id);

    @Select("SELECT song_id FROM playlist_songs WHERE playlist_id = #{playlistId}")
    List<Integer> selectSongIdsByPlaylistId(@Param("playlistId") Integer playlistId);

    @Select("select * from songs where song_id = #{songId}")
    List<Song> selectById(Integer songId);

    // 在PlayListDetailsMapper接口中添加
    @Select({
            "<script>",
            "SELECT * FROM songs",
            "WHERE song_id IN",
            "<foreach item='songId' collection='songIds' open='(' separator=',' close=')'>",
            "#{songId}",
            "</foreach>",
            "</script>"
    })
    List<Song> selectSongsByIds(@Param("songIds") List<Integer> songIds);

}
